package thread;

public class ThreadJoinAndYieldTest extends Thread{

	public static void main(String[] args) throws InterruptedException {
		ThreadJoinAndYieldTest t = new ThreadJoinAndYieldTest();
		Thread thread = new Thread(t);
		t.start();
		for(int i = 0 ;i < 1000; i++){
//			if(500 == i){
//				t.join();  //合并线程,阻塞了main线程
//			}
			if(i % 20 == 0){
				Thread.yield();  //暂停本线程，写在哪个线程中暂停哪个线程
			}
			System.out.println("main:"+i);
		}

	}
	
	public void run(){
		for(int i = 0; i < 1000; i++){
			System.out.println("run:"+i);
		}
	}
}
